package cn.lanqiao.facelogin.mapper;

import cn.lanqiao.facelogin.domain.LoginData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface FaceMapper extends BaseMapper<LoginData> {

    @Update("UPDATE information set face_id = #{faceToken} WHERE timestamp = #{phone}")
    boolean addFaceId(@Param("faceToken") String faceToken, @Param("phone") String phone);

    //通过uuid查询faceToken
    @Select("SELECT face_token FROM information WHERE uuid = '${uuid}'")
    String selectFaceToken(String uuid);

    @Select("SELECT tel FROM information WHERE uuid = '${uuid}'")
    String selectTel(String uuid);

    @Select("SELECT uuid FROM information WHERE tel = ${tel}")
    String selectUUid(String tel);

    @Select("SELECT phone FROM information WHERE face_id = ${faceId}")
    String selectPhone(String tel);


//    @Select("SELECT face_token FROM information WHERE tel = ${tel}")
//    String selectFaceToken(String tel);

    @Select("SELECT token_id FROM information WHERE token_id = ${tokenId}")
    String findTokenId(String tokenId);

    @Select("INSERT INTO information (token_id,u_name) VALUES (${tokenId},${name})")
    String addToken(String tokenId, String name);

    @Select("SELECT tel FROM information WHERE tel = ${tokenId}")
    String findTokenIdTel(String tokenId);
}
